eeprom17 2.2.0
Loading...
Searching...
No Matches
eeprom17.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef EEPROM17_H
29#define EEPROM17_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
58
63
68
73// TODO -- dodati makroe koji definisu adrese registara
74 // eeprom17_reg
76
81
86
91#define EEPROM17_MEM_PAGE_BITMASK 0xF0
92#define EEPROM17_MEM_PAGE_SIZE 16
93#define EEPROM17_MEM_BANK_SIZE 256
94
99#define EEPROM17_BANK_SEL_0 0x00
100#define EEPROM17_BANK_SEL_1 0x01
101
107#define EEPROM17_DEVICE_ADDRESS_0 0x50
108#define EEPROM17_DEVICE_ADDRESS_1 0x52
109 // eeprom17_set
111
116
121
126#define EEPROM17_MAP_MIKROBUS( cfg, mikrobus ) \
127 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
128 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
129 cfg.wc = MIKROBUS( mikrobus, MIKROBUS_PWM );
130 // eeprom17_map // eeprom17
133
138typedef struct
139{
140 // Output pins
141 digital_out_t wc;
142
143 // Modules
144 i2c_master_t i2c;
145
146 // I2C slave address
148
149} eeprom17_t;
150
155typedef struct
156{
157 pin_name_t scl;
158 pin_name_t sda;
159
160 pin_name_t wc;
161
162 uint32_t i2c_speed;
163 uint8_t i2c_address;
164
166
171typedef enum
172{
175
177
183
194
209
222err_t eeprom17_write_memory ( eeprom17_t *ctx, uint8_t address, uint8_t *data_in, uint8_t len );
223
236err_t eeprom17_read_memory ( eeprom17_t *ctx, uint8_t address, uint8_t *data_out, uint16_t len );
237
246void eeprom17_set_wc_pin ( eeprom17_t *ctx, uint8_t state );
247
258err_t eeprom17_select_bank ( eeprom17_t *ctx, uint8_t bank_sel );
259
260#ifdef __cplusplus
261}
262#endif
263#endif // EEPROM17_H
264 // eeprom17
266
267// ------------------------------------------------------------------------ END
eeprom17_return_value_t
EEPROM 17 Click return value data.
Definition eeprom17.h:172
@ EEPROM17_OK
Definition eeprom17.h:173
@ EEPROM17_ERROR
Definition eeprom17.h:174
err_t eeprom17_write_memory(eeprom17_t *ctx, uint8_t address, uint8_t *data_in, uint8_t len)
EEPROM 17 Write Memory function.
void eeprom17_set_wc_pin(eeprom17_t *ctx, uint8_t state)
EEPROM 17 Set Write Control Pin function.
err_t eeprom17_init(eeprom17_t *ctx, eeprom17_cfg_t *cfg)
EEPROM 17 initialization function.
err_t eeprom17_select_bank(eeprom17_t *ctx, uint8_t bank_sel)
EEPROM 17 Select Memory Bank function.
err_t eeprom17_read_memory(eeprom17_t *ctx, uint8_t address, uint8_t *data_out, uint16_t len)
EEPROM 17 Read Memory function.
void eeprom17_cfg_setup(eeprom17_cfg_t *cfg)
EEPROM 17 configuration object setup function.
EEPROM 17 Click configuration object.
Definition eeprom17.h:156
uint32_t i2c_speed
Definition eeprom17.h:162
pin_name_t wc
Definition eeprom17.h:160
pin_name_t scl
Definition eeprom17.h:157
pin_name_t sda
Definition eeprom17.h:158
uint8_t i2c_address
Definition eeprom17.h:163
EEPROM 17 Click context object.
Definition eeprom17.h:139
digital_out_t wc
Definition eeprom17.h:141
i2c_master_t i2c
Definition eeprom17.h:144
uint8_t slave_address
Definition eeprom17.h:147